package com.insurance.modules.partner.controller;

import java.util.Arrays;
import java.util.Map;
import java.util.UUID;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.insurance.entity.PartnerLoginLogEntity;
import com.insurance.service.PartnerLoginLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.insurance.common.utils.PageUtils;
import com.insurance.common.utils.R;



/**
 * 合作方登录日志
 *
 * @date 2021-02-26 17:32:47
 */
@RestController
@RequestMapping("partner/partnerloginlog")
public class PartnerLoginLogController {

    @Autowired
    private PartnerLoginLogService partnerLoginLogService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("partner:partnerloginlog:list")
    public R list(@RequestParam Map<String, Object> params, PartnerLoginLogEntity partnerLoginLogEntity){
        QueryWrapper<PartnerLoginLogEntity> queryWrapper = partnerLoginLogService.getQueryWrapper(partnerLoginLogEntity);
        PageUtils page = partnerLoginLogService.queryPage(params, queryWrapper);
        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{logId}")
    @RequiresPermissions("partner:partnerloginlog:info")
    public R info(@PathVariable("logId") Long logId){
		PartnerLoginLogEntity partnerLoginLog = partnerLoginLogService.getById(logId);
        return R.ok().put("partnerLoginLog", partnerLoginLog);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("partner:partnerloginlog:save")
    public R save(@RequestBody PartnerLoginLogEntity partnerLoginLog){
        partnerLoginLog.setLogId(UUID.randomUUID().toString().replaceAll("-", ""));
		partnerLoginLogService.save(partnerLoginLog);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("partner:partnerloginlog:update")
    public R update(@RequestBody PartnerLoginLogEntity partnerLoginLog){
		partnerLoginLogService.updateById(partnerLoginLog);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("partner:partnerloginlog:delete")
    public R delete(@RequestBody Long[] logIds){
		partnerLoginLogService.removeByIds(Arrays.asList(logIds));
        return R.ok();
    }

}
